import { Field, ObjectType } from '@nestjs/graphql';
import { SharedEntity } from 'src/modules/shared/entities/shared.entity';
import { Column, Entity, Index, Unique } from 'typeorm';
@ObjectType()
@Entity('user')
export class UserEntity extends SharedEntity {
  @Field({ description: '用户名' })
  @Index('username_unique', { unique: true })
  @Column({
    type: 'varchar',
    nullable: false,
    length: 45,
    unique: true,
    name: 'username',
    comment: '用户名',
  })
  username: string;

  @Field({ description: '密码' })
  @Column({
    type: 'varchar',
    nullable: false,
    length: 100,
    name: 'password',
    comment: '密码',
  })
  password: string;

  @Field({ nullable: false, description: '手机号码' })
  @Index('mobile_unique', { unique: true })
  @Column({
    type: 'varchar',
    nullable: true,
    length: 110,
    unique: true,
    name: 'mobile',
    comment: '手机号码',
  })
  mobile: string;
}
